package com.itheima.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.commit.R;
import com.itheima.pojo.Category;
import com.itheima.service.CategoryService;
import com.itheima.service.DishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @PostMapping
    public R<String> add(@RequestBody Category category){
        return categoryService.add(category);
    }
    @GetMapping("/page")
    public R<Page> selectAll(Integer page,Integer pageSize){

        return categoryService.selectAll(page,pageSize);
    }
    @DeleteMapping
    public R<String> delete(Long id){
        return categoryService.delete(id);
    }
    @PutMapping
    public R<String> update(@RequestBody Category category){
        return categoryService.update(category);
    }

    @GetMapping("/list")
    public R<List<Category>> list(Category category){
        return categoryService.list(category);
    }
}
